﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AutoDb {
	/// <summary>
	/// 
	/// </summary>
	sealed class ConsoleLogWriter : ILogWriter {
		/// <summary>
		/// 
		/// </summary>
		public LogLevel Level { get; set; }

		/// <summary>
		/// 
		/// </summary>
		/// <param name="level"></param>
		/// <param name="s"></param>
		public void Write(LogLevel level, string s) {
			Console.BackgroundColor = ConsoleColor.Black;

			switch (level) {
				case LogLevel.Error:
					Console.ForegroundColor = ConsoleColor.Red;
					break;
				case LogLevel.Good:
					Console.ForegroundColor = ConsoleColor.Green;
					break;
				case LogLevel.Warn:
					Console.ForegroundColor = ConsoleColor.Yellow;
					break;
				case LogLevel.Title:
					Console.ForegroundColor = ConsoleColor.White;
					break;
				case LogLevel.Info:
					Console.ForegroundColor = ConsoleColor.Gray;
					break;
				case LogLevel.Verbose:
					Console.ForegroundColor = ConsoleColor.DarkGray;
					break;
				default:
					System.Diagnostics.Debug.Assert(false, "", "Unknown level: \"{0}\".", level);
					return;
			}

			Console.Write(s);
		}

		/// <summary>
		/// 
		/// </summary>
		/// <param name="level"></param>
		public void WriteLine(LogLevel level) {
			Console.WriteLine();
		}

		/// <summary>
		/// 
		/// </summary>
		public void Close() {
			Console.ResetColor();
		}
	} // end of ConsoleLogWriter.
}
